import React from 'react';
import _ from 'lodash';
import { Tooltip } from 'antd';
import styled from 'styled-components';
import { TextWithTags } from '@/components/BaseTable';
import HeaderRenderer from '@/components/BaseTable/HeaderRenderer';
/* eslint no-useless-escape:0 import/prefer-default-export:0 */

const TableCell = styled.div`
  display: flex;
  align-items: center;
  text-align: center;
  justify-content: center;
  flex-direction: column;
`;

export const setFixedColumn = (currentYear, type, currentMonths, currentShowGroup) => {
  const fixedColumns = [];
  let key = '';
  // if 月合计 12 else 1
  const length = type === 'yearEarlyBottomList' ? 12 : 1;
  for (let i = 1; i <= length; i++) {
    if (length === 12 && _.includes(currentMonths, i.toString())) {
      key = currentYear + type + i;
      if (!currentShowGroup || currentShowGroup.search('期初存货') > -1) {
        fixedColumns.push(
          {
            key: `${key}f_monthlyInventoryNum`,
            align: 'right',
            width: 200,
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={3}>
                  <div>套数/车位数</div>
                </HeaderRenderer>
              </div>
            ),
            dataGetter: ({ rowData }) => {
              const text = rowData.yearEarlyBottomList[i - 1].f_monthlyInventoryNum;
              // rowData.overallPlanAndActual.price
              const result = {
                text,
              };
              result.textFirst = true;
              return result;
            },
            cellRenderer: data => <TextWithTags {...data} />,
          },
          // 月初存货
          {
            key: `${key}f_monthlyInventoryAmount`,
            align: 'right',
            width: 200,
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={3}>
                  <div>金额(万元：合计/房源/车位)</div>
                </HeaderRenderer>
              </div>
            ),
            dataGetter: ({ rowData }) => {
              const text = rowData.yearEarlyBottomList[i - 1].f_monthlyInventoryAmount;
              // rowData.overallPlanAndActual.price
              const result = {
                text,
              };
              result.textFirst = true;
              return result;
            },
            cellRenderer: data => <TextWithTags {...data} />,
          },
          // 月初存货 签约计划
          {
            key: `${key}f_signingPlanNum`,
            align: 'right',
            width: 200,
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={3}>
                  <div>套数/车位数</div>
                </HeaderRenderer>
              </div>
            ),
            dataGetter: ({ rowData }) => {
              const text = rowData.yearEarlyBottomList[i - 1].f_signingPlanNum;
              // rowData.overallPlanAndActual.price
              const result = {
                text,
              };
              result.textFirst = true;
              return result;
            },
            cellRenderer: data => <TextWithTags {...data} />,
          },
          {
            key: `${key}f_signingPlanAmount`,
            align: 'right',
            width: 200,
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={3}>
                  <div>金额(万元：合计/房源/车位)</div>
                </HeaderRenderer>
              </div>
            ),
            dataGetter: ({ rowData }) => {
              const text = rowData.yearEarlyBottomList[i - 1].f_signingPlanAmount;
              // rowData.overallPlanAndActual.price
              const result = {
                text,
              };
              result.textFirst = true;
              return result;
            },
            cellRenderer: data => <TextWithTags {...data} />,
          },
          // 月初存货 签约实际
          {
            key: `${key}f_signingActualNum`,
            align: 'right',
            width: 200,
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={3}>
                  <div>套数/车位数</div>
                </HeaderRenderer>
              </div>
            ),
            dataGetter: ({ rowData }) => {
              const text = rowData.yearEarlyBottomList[i - 1].f_signingActualNum;
              // rowData.overallPlanAndActual.price
              const result = {
                text,
              };
              result.textFirst = true;
              return result;
            },
            cellRenderer: data => <TextWithTags {...data} />,
          },
          {
            key: `${key}f_signingActualAmount`,
            align: 'right',
            width: 200,
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={3}>
                  <div>金额(万元：合计/房源/车位)</div>
                </HeaderRenderer>
              </div>
            ),
            dataGetter: ({ rowData }) => {
              const text = rowData.yearEarlyBottomList[i - 1].f_signingActualAmount;
              // rowData.overallPlanAndActual.price
              const result = {
                text,
              };
              result.textFirst = true;
              return result;
            },
            cellRenderer: data => <TextWithTags {...data} />,
          },
          // 月初存货 签约达成率
          {
            key: `${key}f_signingRateAmount`,
            align: 'right',
            width: 100,
            headerRenderer: () => (
              <div>
                <div>( % )</div>
              </div>
            ),
            dataGetter: ({ rowData }) => {
              const text = rowData.yearEarlyBottomList[i - 1].f_signingRateAmount;
              // rowData.overallPlanAndActual.price
              const result = {
                text,
              };
              result.textFirst = true;
              return result;
            },
            cellRenderer: data => <TextWithTags {...data} />,
          },
          // 月初存货 计划去化率
          {
            key: `${key}f_planDeChemicalRateAmount`,
            align: 'right',
            width: 100,
            headerRenderer: () => (
              <div>
                <div>( % )</div>
              </div>
            ),
            dataGetter: ({ rowData }) => {
              const text = rowData.yearEarlyBottomList[i - 1].f_planDeChemicalRateAmount;
              // rowData.overallPlanAndActual.price
              const result = {
                text,
              };
              result.textFirst = true;
              return result;
            },
            cellRenderer: data => <TextWithTags {...data} />,
          },
        );
      }
      if (!currentShowGroup || currentShowGroup.search('新供') > -1) {
        fixedColumns.push(
          // 月度新供 供货计划
          {
            key: `${key}g_supplyPlanNum`,
            align: 'right',
            width: 200,
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={1}>
                  <div>套数/车位数</div>
                </HeaderRenderer>
              </div>
            ),
            dataGetter: ({ rowData }) => {
              const text = rowData.yearEarlyBottomList[i - 1].g_supplyPlanNum;
              // rowData.overallPlanAndActual.price
              const result = {
                text,
              };
              result.textFirst = true;
              return result;
            },
            cellRenderer: data => <TextWithTags {...data} />,
          },
          {
            key: `${key}g_supplyPlanAmount`,
            align: 'right',
            width: 200,
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={3}>
                  <div>金额(万元：合计/房源/车位)</div>
                </HeaderRenderer>
              </div>
            ),
            dataGetter: ({ rowData }) => {
              const text = rowData.yearEarlyBottomList[i - 1].g_supplyPlanAmount;
              // rowData.overallPlanAndActual.price
              const result = {
                text,
              };
              result.textFirst = true;
              return result;
            },
            cellRenderer: data => <TextWithTags {...data} />,
          },
          // 月度新供 供货实际
          {
            key: `${key}g_supplyPlanActualNum`,
            align: 'right',
            width: 200,
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={3}>
                  <div>套数/车位数</div>
                </HeaderRenderer>
              </div>
            ),
            dataGetter: ({ rowData }) => {
              const text = rowData.yearEarlyBottomList[i - 1].g_supplyPlanActualNum;
              // rowData.overallPlanAndActual.price
              const result = {
                text,
              };
              result.textFirst = true;
              return result;
            },
            cellRenderer: data => <TextWithTags {...data} />,
          },
          {
            key: `${key}g_supplyPlanActualAmount`,
            align: 'right',
            width: 200,
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={3}>
                  <div>金额(万元：合计/房源/车位)</div>
                </HeaderRenderer>
              </div>
            ),
            dataGetter: ({ rowData }) => {
              const text = rowData.yearEarlyBottomList[i - 1].g_supplyPlanActualAmount;
              // rowData.overallPlanAndActual.price
              const result = {
                text,
              };
              result.textFirst = true;
              return result;
            },
            cellRenderer: data => <TextWithTags {...data} />,
          },
          // 月度新供 供货达成率
          {
            key: `${key}g_supplyPlanRateAmount`,
            align: 'right',
            width: 100,
            headerRenderer: () => (
              <div>
                <div>( % )</div>
              </div>
            ),
            dataGetter: ({ rowData }) => {
              const text = rowData.yearEarlyBottomList[i - 1].g_supplyPlanRateAmount;
              // rowData.overallPlanAndActual.price
              const result = {
                text,
              };
              result.textFirst = true;
              return result;
            },
            cellRenderer: data => <TextWithTags {...data} />,
          },
          // 月度新供 签约计划
          {
            key: `${key}g_signingPlanNum`,
            align: 'right',
            width: 200,
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={3}>
                  <div>套数/车位数</div>
                </HeaderRenderer>
              </div>
            ),
            dataGetter: ({ rowData }) => {
              const text = rowData.yearEarlyBottomList[i - 1].g_signingPlanNum;
              // rowData.overallPlanAndActual.price
              const result = {
                text,
              };
              result.textFirst = true;
              return result;
            },
            cellRenderer: data => <TextWithTags {...data} />,
          },
          {
            key: `${key}g_signingPlanAmount`,
            align: 'right',
            width: 200,
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={3}>
                  <div>金额(万元：合计/房源/车位)</div>
                </HeaderRenderer>
              </div>
            ),
            dataGetter: ({ rowData }) => {
              const text = rowData.yearEarlyBottomList[i - 1].g_signingPlanAmount;
              // rowData.overallPlanAndActual.price
              const result = {
                text,
              };
              result.textFirst = true;
              return result;
            },
            cellRenderer: data => <TextWithTags {...data} />,
          },
          // 月度新供 签约实际
          {
            key: `${key}g_signingActualNum`,
            align: 'right',
            width: 200,
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={3}>
                  <div>套数/车位数</div>
                </HeaderRenderer>
              </div>
            ),
            dataGetter: ({ rowData }) => {
              const text = rowData.yearEarlyBottomList[i - 1].g_signingActualNum;
              // rowData.overallPlanAndActual.price
              const result = {
                text,
              };
              result.textFirst = true;
              return result;
            },
            cellRenderer: data => <TextWithTags {...data} />,
          },
          {
            key: `${key}g_signingActualAmount`,
            align: 'right',
            width: 200,
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={3}>
                  <div>金额(万元：合计/房源/车位)</div>
                </HeaderRenderer>
              </div>
            ),
            dataGetter: ({ rowData }) => {
              const text = rowData.yearEarlyBottomList[i - 1].g_signingActualAmount;
              // rowData.overallPlanAndActual.price
              const result = {
                text,
              };
              result.textFirst = true;
              return result;
            },
            cellRenderer: data => <TextWithTags {...data} />,
          },
          // 月度新供 签约达成率
          {
            key: `${key}g_signingRateAmount`,
            align: 'right',
            width: 100,
            headerRenderer: () => (
              <div>
                <div>( % )</div>
              </div>
            ),
            dataGetter: ({ rowData }) => {
              const text = rowData.yearEarlyBottomList[i - 1].g_signingRateAmount;
              // rowData.overallPlanAndActual.price
              const result = {
                text,
              };
              result.textFirst = true;
              return result;
            },
            cellRenderer: data => <TextWithTags {...data} />,
          },
          // 月度新供 计划去化率
          {
            key: `${key}g_planDeChemicalRateAmount`,
            align: 'right',
            width: 100,
            headerRenderer: () => (
              <div>
                <div>( % )</div>
              </div>
            ),
            dataGetter: ({ rowData }) => {
              const text = rowData.yearEarlyBottomList[i - 1].g_planDeChemicalRateAmount;
              // rowData.overallPlanAndActual.price
              const result = {
                text,
              };
              result.textFirst = true;
              return result;
            },
            cellRenderer: data => <TextWithTags {...data} />,
          },
        );
      }
      if (!currentShowGroup || currentShowGroup.search('综合') > -1) {
        fixedColumns.push(
          // 月度综合 月度可售
          {
            key: `${key}h_monthlyAvailableNum`,
            align: 'right',
            width: 200,
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={3}>
                  <div>套数/车位数</div>
                </HeaderRenderer>
              </div>
            ),
            dataGetter: ({ rowData }) => {
              const text = rowData.yearEarlyBottomList[i - 1].h_monthlyAvailableNum;
              // rowData.overallPlanAndActual.price
              const result = {
                text,
              };
              result.textFirst = true;
              return result;
            },
            cellRenderer: data => <TextWithTags {...data} />,
          },
          {
            key: `${key}h_monthlyAvailableAmount`,
            align: 'right',
            width: 200,
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={3}>
                  <div>金额(万元：合计/房源/车位)</div>
                </HeaderRenderer>
              </div>
            ),
            dataGetter: ({ rowData }) => {
              const text = rowData.yearEarlyBottomList[i - 1].h_monthlyAvailableAmount;
              // rowData.overallPlanAndActual.price
              const result = {
                text,
              };
              result.textFirst = true;
              return result;
            },
            cellRenderer: data => <TextWithTags {...data} />,
          },
          // 月度综合 签约计划
          {
            key: `${key}h_signingPlanNum`,
            align: 'right',
            width: 200,
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={3}>
                  <div>套数/车位数</div>
                </HeaderRenderer>
              </div>
            ),
            dataGetter: ({ rowData }) => {
              const text = rowData.yearEarlyBottomList[i - 1].h_signingPlanNum;
              // rowData.overallPlanAndActual.price
              const result = {
                text,
              };
              result.textFirst = true;
              return result;
            },
            cellRenderer: data => <TextWithTags {...data} />,
          },
          {
            key: `${key}h_signingPlanAmount`,
            align: 'right',
            width: 200,
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={3}>
                  <div>金额(万元：合计/房源/车位)</div>
                </HeaderRenderer>
              </div>
            ),
            dataGetter: ({ rowData }) => {
              const text = rowData.yearEarlyBottomList[i - 1].h_signingPlanAmount;
              // rowData.overallPlanAndActual.price
              const result = {
                text,
              };
              result.textFirst = true;
              return result;
            },
            cellRenderer: data => <TextWithTags {...data} />,
          },
          // 月度综合 签约实际
          {
            key: `${key}h_signingActualNum`,
            align: 'right',
            width: 200,
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={3}>
                  <div>套数/车位数</div>
                </HeaderRenderer>
              </div>
            ),
            dataGetter: ({ rowData }) => {
              const text = rowData.yearEarlyBottomList[i - 1].h_signingActualNum;
              // rowData.overallPlanAndActual.price
              const result = {
                text,
              };
              result.textFirst = true;
              return result;
            },
            cellRenderer: data => <TextWithTags {...data} />,
          },
          {
            key: `${key}h_signingActualAmount`,
            align: 'right',
            width: 200,
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={3}>
                  <div>金额(万元：合计/房源/车位)</div>
                </HeaderRenderer>
              </div>
            ),
            dataGetter: ({ rowData }) => {
              const text = rowData.yearEarlyBottomList[i - 1].h_signingActualAmount;
              // rowData.overallPlanAndActual.price
              const result = {
                text,
              };
              result.textFirst = true;
              return result;
            },
            cellRenderer: data => <TextWithTags {...data} />,
          },
          // 月度综合 签约达成率
          {
            key: `${key}h_signingRateAmount`,
            align: 'right',
            width: 100,
            headerRenderer: () => (
              <div>
                <div>( % )</div>
              </div>
            ),
            dataGetter: ({ rowData }) => {
              const text = rowData.yearEarlyBottomList[i - 1].h_signingRateAmount;
              // rowData.overallPlanAndActual.price
              const result = {
                text,
              };
              result.textFirst = true;
              return result;
            },
            cellRenderer: data => <TextWithTags {...data} />,
          },
          // 月度综合 计划去化率
          {
            key: `${key}h_planDeChemicalRateAmount`,
            align: 'right',
            width: 100,
            headerRenderer: () => (
              <div>
                <div>( % )</div>
              </div>
            ),
            dataGetter: ({ rowData }) => {
              const text = rowData.yearEarlyBottomList[i - 1].h_planDeChemicalRateAmount;
              // rowData.overallPlanAndActual.price
              const result = {
                text,
              };
              result.textFirst = true;
              return result;
            },
            cellRenderer: data => <TextWithTags {...data} />,
          },
        );
      }
    }
  }

  return fixedColumns;
};
export const getFixedColumns = (currentYear, currentMonths, currentShowGroup) => {
  let fixedColumns = [
    {
      key: 'name',
      dataKey: 'name',
      title: '',
      width: 300,
      frozen: 'left',
      dataGetter: ({ rowData }) => {
        const text = rowData.name;
        const result = {
          text,
        };
        result.textFirst = true;
        if (rowData.isSupply === 0) {
          result.tags = [{ text: '未供', color: 'orange', border: true }];
        }
        if (rowData.isSupply === 1) {
          result.tags = [{ text: '已供', color: 'green' }];
        }
        return result;
      },
      cellRenderer: data => {
        const title =
          data.rowData.type === 'org_product'
            ? `${data.rowData.name}-${data.rowData.freeTypeName}-${data.rowData.businessTypeName}-${data.rowData.proTypeName}`
            : data.rowData.name;
        return (
          <div
            style={{
              width: '100%',
              textOverflow: 'ellipsis',
              whiteSpace: 'nowrap',
              overflow: 'hidden',
            }}
          >
            <Tooltip placement="topLeft" title={title}>
              {title}
            </Tooltip>
          </div>
        );
      },
    },
    {
      key: 'carryOverTimeStr',
      dataKey: 'carryOverTimeStr',
      title: '结转日期',
      width: 100,
      frozen: 'left',
    },
    {
      key: 'availableNum',
      headerRenderer: () => (
        <div>
          <HeaderRenderer type={1}>
            <div>套数/车位数</div>
          </HeaderRenderer>
        </div>
      ),
      align: 'right',
      width: 200,
      cellRenderer: data => data.rowData.supplyAndSign.availableNum,
    },
    {
      key: 'availableAmount',
      headerRenderer: () => (
        <div>
          <HeaderRenderer type={3}>
            <div>金额(万元：合计/房源/车位)</div>
          </HeaderRenderer>
        </div>
      ),
      align: 'right',
      width: 200,
      cellRenderer: data => data.rowData.supplyAndSign.availableAmount,
    },
    {
      key: 'accumulativeSupplyNum',
      headerRenderer: () => (
        <div>
          <HeaderRenderer type={1}>
            <div>套数/车位数</div>
          </HeaderRenderer>
        </div>
      ),
      align: 'right',
      width: 200,
      cellRenderer: data => data.rowData.supplyAndSign.accumulativeSupplyNum,
    },
    {
      key: 'accumulativeSupplyAmount',
      align: 'right',
      headerRenderer: () => (
        <div>
          <HeaderRenderer type={3}>
            <div>金额(万元：合计/房源/车位)</div>
          </HeaderRenderer>
        </div>
      ),
      cellRenderer: data => data.rowData.supplyAndSign.accumulativeSupplyAmount,
      width: 200,
    },
    {
      key: 'deliveryCompletionRate',
      title: '( % )',
      align: 'right',
      cellRenderer: data => data.rowData.supplyAndSign.deliveryCompletionRate,
      width: 100,
    },
    {
      key: 'accumulativeSoldNum',
      headerRenderer: () => (
        <div>
          <HeaderRenderer type={1}>
            <div>套数/车位数</div>
          </HeaderRenderer>
        </div>
      ),
      align: 'right',
      cellRenderer: data => data.rowData.supplyAndSign.accumulativeSoldNum,
      width: 200,
    },
    {
      key: 'accumulativeSold',
      headerRenderer: () => (
        <div>
          <HeaderRenderer type={3}>
            <div>金额(万元：合计/房源/车位)</div>
          </HeaderRenderer>
        </div>
      ),
      align: 'right',
      cellRenderer: data => data.rowData.supplyAndSign.accumulativeSold,
      width: 200,
    },
    {
      key: 'contractCompletionRate',
      title: '( % )',
      align: 'right',
      cellRenderer: data => data.rowData.supplyAndSign.contractCompletionRate,
      width: 100,
    },
    {
      key: 'actualRemovalRate',
      title: '( % )',
      align: 'right',
      cellRenderer: data => data.rowData.supplyAndSign.actualRemovalRate,
      width: 100,
    },
  ];
  if (_.includes(currentMonths, '14'.toString())) {
    if (!currentShowGroup || currentShowGroup.search('期初存货') > -1) {
      fixedColumns.push(
        ...[
          // 年度供货签约合计
          // 年初新供
          {
            key: 'c_earlyInventoryNum',
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={1}>
                  <div>套数/车位数</div>
                </HeaderRenderer>
              </div>
            ),
            align: 'right',
            cellRenderer: data => data.rowData.yearDepositNewSupply.c_earlyInventoryNum,
            width: 200,
          },
          {
            key: 'c_earlyInventoryAmount',
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={3}>
                  <div>金额(万元：合计/房源/车位)</div>
                </HeaderRenderer>
              </div>
            ),
            align: 'right',
            cellRenderer: data => data.rowData.yearDepositNewSupply.c_earlyInventoryAmount,
            width: 200,
          },
          {
            key: 'yearDepositNewSupply_c_actualContractNum',
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={1}>
                  <div>套数/车位数</div>
                </HeaderRenderer>
              </div>
            ),
            align: 'right',
            cellRenderer: data => data.rowData.yearDepositNewSupply.c_actualContractNum,
            width: 200,
          },
          {
            key: 'yearDepositNewSupply_c_actualContractAmount',
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={3}>
                  <div>金额(万元：合计/房源/车位)</div>
                </HeaderRenderer>
              </div>
            ),
            align: 'right',
            cellRenderer: data => data.rowData.yearDepositNewSupply.c_actualContractAmount,
            width: 200,
          },
          {
            key: 'c_actualDeChemicalRateAmount',
            title: '( % )',
            align: 'right',
            cellRenderer: data => data.rowData.yearDepositNewSupply.c_actualDeChemicalRateAmount,
            width: 100,
          },
        ],
      );
    }

    if (!currentShowGroup || currentShowGroup.search('新供') > -1) {
      fixedColumns.push(
        ...[
          {
            key: 'd_supplyPlanNum',
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={1}>
                  <div>套数/车位数</div>
                </HeaderRenderer>
              </div>
            ),
            align: 'right',
            cellRenderer: data => data.rowData.yearDepositNewSupply.d_supplyPlanNum,
            width: 200,
          },
          {
            key: 'd_supplyPlanAmount',
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={3}>
                  <div>金额(万元：合计/房源/车位)</div>
                </HeaderRenderer>
              </div>
            ),
            align: 'right',
            cellRenderer: data => data.rowData.yearDepositNewSupply.d_supplyPlanAmount,
            width: 200,
          },
          {
            key: 'd_supplyPlanActualNum',
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={1}>
                  <div>套数/车位数</div>
                </HeaderRenderer>
              </div>
            ),
            align: 'right',
            cellRenderer: data => data.rowData.yearDepositNewSupply.d_supplyPlanActualNum,
            width: 200,
          },
          {
            key: 'd_supplyPlanActualAmount',
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={3}>
                  <div>金额(万元：合计/房源/车位)</div>
                </HeaderRenderer>
              </div>
            ),
            align: 'right',
            cellRenderer: data => data.rowData.yearDepositNewSupply.d_supplyPlanActualAmount,
            width: 200,
          },
          {
            key: 'd_supplyPlanRateAmount',
            title: '( % )',
            align: 'right',
            cellRenderer: data => data.rowData.yearDepositNewSupply.d_supplyPlanRateAmount,
            width: 100,
          },
          {
            key: 'd_actualContractNum',
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={1}>
                  <div>套数/车位数</div>
                </HeaderRenderer>
              </div>
            ),
            align: 'right',
            cellRenderer: data => data.rowData.yearDepositNewSupply.d_actualContractNum,
            width: 200,
          },
          {
            key: 'd_actualContractAmount',
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={3}>
                  <div>金额(万元：合计/房源/车位)</div>
                </HeaderRenderer>
              </div>
            ),
            align: 'right',
            cellRenderer: data => data.rowData.yearDepositNewSupply.d_actualContractAmount,
            width: 200,
          },
          {
            key: 'd_actualDeChemicalRateAmount',
            title: '( % )',
            align: 'right',
            cellRenderer: data => data.rowData.yearDepositNewSupply.d_actualDeChemicalRateAmount,
            width: 100,
          },
        ],
      );
    }
    if (!currentShowGroup || currentShowGroup.search('综合') > -1) {
      fixedColumns.push(
        ...[
          {
            key: 'e_annualSaleNum',
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={1}>
                  <div>套数/车位数</div>
                </HeaderRenderer>
              </div>
            ),
            align: 'right',
            cellRenderer: data => data.rowData.yearDepositNewSupply.e_annualSaleNum,
            width: 200,
          },
          {
            key: 'e_annualSaleAmount',
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={3}>
                  <div>金额(万元：合计/房源/车位)</div>
                </HeaderRenderer>
              </div>
            ),
            align: 'right',
            cellRenderer: data => data.rowData.yearDepositNewSupply.e_annualSaleAmount,
            width: 200,
          },
          {
            key: 'yearSigningTargetCount',
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={1}>
                  <div>套数/车位数</div>
                </HeaderRenderer>
              </div>
            ),
            align: 'right',
            cellRenderer: data => data.rowData.yearDepositNewSupply.yearSigningTargetCount,
            width: 200,
          },
          {
            key: 'yearSigningTargetAmount',
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={3}>
                  <div>金额(万元：合计/房源/车位)</div>
                </HeaderRenderer>
              </div>
            ),
            align: 'right',
            cellRenderer: data => data.rowData.yearDepositNewSupply.yearSigningTargetAmount,
            width: 200,
          },
          {
            key: 'e_signingPlanNum',
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={1}>
                  <div>套数/车位数</div>
                </HeaderRenderer>
              </div>
            ),
            align: 'right',
            cellRenderer: data => data.rowData.yearDepositNewSupply.e_signingPlanNum,
            width: 200,
          },
          {
            key: 'e_signingPlanAmount',
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={3}>
                  <div>金额(万元：合计/房源/车位)</div>
                </HeaderRenderer>
              </div>
            ),
            align: 'right',
            cellRenderer: data => data.rowData.yearDepositNewSupply.e_signingPlanAmount,
            width: 200,
          },
          {
            key: 'e_signingActualNum',
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={1}>
                  <div>套数/车位数</div>
                </HeaderRenderer>
              </div>
            ),
            align: 'right',
            cellRenderer: data => data.rowData.yearDepositNewSupply.e_signingActualNum,
            width: 200,
          },
          {
            key: 'e_signingActualAmount',
            headerRenderer: () => (
              <div>
                <HeaderRenderer type={3}>
                  <div>金额(万元：合计/房源/车位)</div>
                </HeaderRenderer>
              </div>
            ),
            align: 'right',
            cellRenderer: data => data.rowData.yearDepositNewSupply.e_signingActualAmount,
            width: 200,
          },
          {
            key: 'e_signingRateAmount',
            title: '( % )',
            align: 'right',
            cellRenderer: data => data.rowData.yearDepositNewSupply.e_signingRateAmount,
            width: 100,
          },
          {
            key: 'e_actualDeChemicalRateAmount',
            title: '( % )',
            align: 'right',
            cellRenderer: data => data.rowData.yearDepositNewSupply.e_actualDeChemicalRateAmount,
            width: 100,
          },
          {
            key: 'e_planDeChemicalRateAmount',
            title: '( % )',
            align: 'right',
            cellRenderer: data => data.rowData.yearDepositNewSupply.e_planDeChemicalRateAmount,
            width: 100,
          },
        ],
      );
    }
  }
  // 供货月合计
  fixedColumns = _.concat(
    fixedColumns,
    setFixedColumn(currentYear, 'yearEarlyBottomList', currentMonths, currentShowGroup),
  );

  return fixedColumns;
};

export const getTitleTree = (currentYear = '', currentMonths, currentShowGroup) => {
  const titleTree = [
    {
      name: '项目/分期/组团/产品类型',
      key: 'id',
      colspan: 1,
      rowspan: 5,
      frozen: 'left',
    },
    {
      name: '结转日期',
      key: 'carryOverTimeStr',
      colspan: 1,
      rowspan: 5,
      frozen: 'left',
      children: [],
    },
    {
      name: '供货与签约',
      key: 'contractPlan',
      rowspan: 2,
      children: [],
    },
    {
      name: '',
      isTabs: true,
      key: 'yearTotalCount',
      children: [],
    },
  ];
  // 供货与签约
  titleTree[2].children = [
    {
      name: (
        <TableCell>
          <div>可售货值</div>
          <div>(A)</div>
        </TableCell>
      ),
      key: 'kshz',
      rowspan: 2,
      marginTop: 1,
      colspan: 2,
    },
    {
      name: (
        <TableCell>
          <div>累计已供</div>
          <div>(B)</div>
        </TableCell>
      ),
      key: 'ljyg',
      rowspan: 2,
      marginTop: 1,
      colspan: 2,
    },
    {
      name: (
        <TableCell>
          <div>供货达成率</div>
          <div>(B/A)</div>
        </TableCell>
      ),
      key: 'ghwcl',
      rowspan: 2,
      marginTop: 1,
      colspan: 1,
    },
    {
      name: (
        <TableCell>
          <div>累计已售</div>
          <div>(C)</div>
        </TableCell>
      ),
      key: 'ljys',
      rowspan: 2,
      marginTop: 1,
      colspan: 2,
    },
    {
      name: (
        <TableCell>
          <div>签约达成率</div>
          <div>(C/A)</div>
        </TableCell>
      ),
      key: 'qywcl',
      rowspan: 2,
      marginTop: 1,
      colspan: 1,
    },
    {
      name: (
        <TableCell>
          <div>实际去化率</div>
          <div>(C/B)</div>
        </TableCell>
      ),
      key: 'sjqhl',
      rowspan: 2,
      marginTop: 1,
      colspan: 1,
    },
  ];
  // table header点击的年份
  const columns = [];
  // 显示年供货合计
  columns.push({
    name: `${currentYear}年年度供货签约合计`,
    key: `${currentYear}qyhj`,
    hidden: !_.includes(currentMonths, '14'),
    children: [
      {
        name: `${currentYear}年初存货`,
        key: `${currentYear}ncch`,
        hidden: currentShowGroup && currentShowGroup.search('期初存货') === -1,
        children: [
          {
            name: '年初存货',
            key: `${currentYear}c_earlyInventoryAmount`,
            colspan: 2,
          },
          {
            name: '实际签约',
            key: `${currentYear}c_actualContractAmount`,
            colspan: 2,
          },
          {
            name: '实际去化率',
            key: `${currentYear}c_actualDeChemicalRateAmount`,
            colspan: 1,
          },
        ],
      },
      {
        name: `${currentYear}年度新供`,
        key: `${currentYear}ndxg`,
        hidden: currentShowGroup && currentShowGroup.search('新供') === -1,
        children: [
          {
            name: '供货计划',
            key: `${currentYear}d_supplyPlanAmount`,
            colspan: 2,
          },
          {
            name: '供货实际',
            key: `${currentYear}d_supplyPlanActualAmount`,
            colspan: 2,
          },
          {
            name: '供货达成率',
            key: `${currentYear}d_supplyPlanRateAmount`,
            colspan: 1,
          },
          {
            name: '实际签约',
            key: `${currentYear}d_actualContractAmount`,
            colspan: 2,
          },
          {
            name: '实际去化率',
            key: `${currentYear}d_actualDeChemicalRateAmount`,
            colspan: 1,
          },
        ],
      },
      {
        name: `${currentYear}年度综合`,
        key: `${currentYear}ndzh`,
        hidden: currentShowGroup && currentShowGroup.search('综合') === -1,
        children: [
          {
            name: '年度可售',
            key: `${currentYear}e_annualSaleAmount`,
            colspan: 2,
          },
          {
            name: '年度签约目标',
            key: `${currentYear}yearSigningTargetAmount`,
            colspan: 2,
          },
          {
            name: '签约计划',
            key: `${currentYear}e_signingPlanAmount`,
            colspan: 2,
          },
          {
            name: '签约实际',
            key: `${currentYear}e_signingActualAmount`,
            colspan: 2,
          },
          {
            name: '签约达成率',
            key: `${currentYear}e_signingRateAmount`,
            colspan: 1,
          },
          {
            name: '实际去化率',
            key: `${currentYear}e_actualDeChemicalRateAmount`,
            colspan: 1,
          },
          {
            name: '计划去化率',
            key: `${currentYear}e_planDeChemicalRateAmount`,
            colspan: 1,
          },
        ],
      },
    ],
  });
  // 月份
  for (let i = 1; i <= 12; i += 1) {
    columns.push({
      name: `${currentYear}-${i < 10 ? '0' : ''}${i}`,
      key: `${currentYear}${i}month`,
      hidden: !_.includes(currentMonths, i.toString()),
      children: [
        {
          name: `${currentYear}-${i < 10 ? '0' : ''}${i}月初存货`,
          key: `${currentYear}month${i}`,
          hidden:
            !_.includes(currentMonths, i.toString()) ||
            (currentShowGroup && currentShowGroup.search('期初存货') === -1),
          colspan: 5,
          children: [
            {
              name: '月初存货',
              key: `${currentYear}f_monthlyInventoryAmount${i}`,
              colspan: 2,
            },
            {
              name: '签约计划',
              key: `${currentYear}f_signingPlanAmount${i}`,
              colspan: 2,
            },
            {
              name: '签约实际',
              key: `${currentYear}f_signingActualAmount${i}`,
              colspan: 2,
            },
            {
              name: '签约达成率',
              key: `${currentYear}f_signingRateAmount${i}`,
              colspan: 1,
            },
            {
              name: '计划去化率',
              key: `${currentYear}f_planDeChemicalRateAmount${i}`,
              colspan: 1,
            },
          ],
        },
        {
          name: `${currentYear}-${i < 10 ? '0' : ''}${i}月度新供`,
          key: `${currentYear}ydxg${i}`,
          hidden:
            !_.includes(currentMonths, i.toString()) ||
            (currentShowGroup && currentShowGroup.search('新供') === -1),
          colspan: 7,
          children: [
            {
              name: '供货计划',
              key: `${currentYear}g_supplyPlanAmount${i}`,
              colspan: 2,
            },
            {
              name: '供货实际',
              key: `${currentYear}g_supplyPlanActualAmount${i}`,
              colspan: 2,
            },
            {
              name: '供货达成率',
              key: `${currentYear}g_supplyPlanRateAmount${i}`,
              colspan: 1,
            },
            {
              name: '签约计划',
              key: `${currentYear}g_signingPlanAmount${i}`,
              colspan: 2,
            },
            {
              name: '签约实际',
              key: `${currentYear}g_signingActualAmount${i}`,
              colspan: 2,
            },
            {
              name: '签约达成率',
              key: `${currentYear}g_signingRateAmount${i}`,
              colspan: 1,
            },
            {
              name: '计划去化率',
              key: `${currentYear}g_planDeChemicalRateAmount${i}`,
              colspan: 1,
            },
          ],
        },
        {
          name: `${currentYear}-${i < 10 ? '0' : ''}${i}月度综合`,
          key: `${currentYear}ydzh${i}`,
          hidden:
            !_.includes(currentMonths, i.toString()) ||
            (currentShowGroup && currentShowGroup.search('综合') === -1),
          colspan: 5,
          children: [
            {
              name: '月度可售',
              key: `${currentYear}h_monthlyAvailableAmount${i}`,
              colspan: 2,
            },
            {
              name: '签约计划',
              key: `${currentYear}h_signingPlanAmount${i}`,
              colspan: 2,
            },
            {
              name: '签约实际',
              key: `${currentYear}h_signingActualAmount${i}`,
              colspan: 2,
            },
            {
              name: '签约达成率',
              key: `${currentYear}h_signingRateAmount${i}`,
              colspan: 1,
            },
            {
              name: '计划去化率',
              key: `${currentYear}h_planDeChemicalRateAmount${i}`,
              colspan: 1,
            },
          ],
        },
      ],
    });
  }
  titleTree[3].children = columns;
  return titleTree;
};
